/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "UNIDAD")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Unidad.findAll", query = "SELECT u FROM Unidad u"),
    @NamedQuery(name = "Unidad.findByUniCod", query = "SELECT u FROM Unidad u WHERE u.uniCod = :uniCod"),
    @NamedQuery(name = "Unidad.findByUniEst", query = "SELECT u FROM Unidad u WHERE u.uniEst = :uniEst"),
    @NamedQuery(name = "Unidad.findByUniDesc", query = "SELECT u FROM Unidad u WHERE u.uniDesc = :uniDesc")})
public class Unidad implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "UNI_COD")
    private Short uniCod;
    @Column(name = "UNI_EST")
    private Short uniEst;
    @Column(name = "UNI_DESC")
    private String uniDesc;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "unidad", fetch = FetchType.LAZY)
    private List<PersonalUnidad> personalUnidadList;

    public Unidad() {
    }

    public Unidad(Short uniCod) {
        this.uniCod = uniCod;
    }

    public Short getUniCod() {
        return uniCod;
    }

    public void setUniCod(Short uniCod) {
        this.uniCod = uniCod;
    }

    public Short getUniEst() {
        return uniEst;
    }

    public void setUniEst(Short uniEst) {
        this.uniEst = uniEst;
    }

    public String getUniDesc() {
        return uniDesc;
    }

    public void setUniDesc(String uniDesc) {
        this.uniDesc = uniDesc;
    }

    @XmlTransient
    public List<PersonalUnidad> getPersonalUnidadList() {
        return personalUnidadList;
    }

    public void setPersonalUnidadList(List<PersonalUnidad> personalUnidadList) {
        this.personalUnidadList = personalUnidadList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (uniCod != null ? uniCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Unidad)) {
            return false;
        }
        Unidad other = (Unidad) object;
        if ((this.uniCod == null && other.uniCod != null) || (this.uniCod != null && !this.uniCod.equals(other.uniCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.Unidad[ uniCod=" + uniCod + " ]";
    }
    
}
